<template>
	<view class="preview" >
		<swiper circular>
			<swiper-item v-for="item in 5" :key="5">
				<image src="/common/images/preview1.jpg" mode="aspectFill" @click="maskChange"></image>
			</swiper-item>
		</swiper>
		<view class="mask" :style="maskState ? 'opacity: 1' : 'opacity: 0'">
			<view class="goBack" :style="{top: statusBarHeight()+ 'px'}" @click="goBack">
				<uni-icons type="back" color="#fff" size="20"></uni-icons>
			</view>
			<view class="count">3 / 9</view>
			<view class="time">
				<uni-dateformat :date="Date.now()" format="hh:mm"></uni-dateformat>
			</view>
			<view class="date">
				<uni-dateformat :date="Date.now()" format="MM月dd日"></uni-dateformat>
			</view>
			<view class="footer">
				<view class="box" @click="openInfoPopup">
					<uni-icons type="info" size="26"></uni-icons>
					<text class="text">信息</text>
				</view>
				<view class="box" @click="openScorePopup">
					<uni-icons type="star" size="26"></uni-icons>
					<text class="text">评分</text>
				</view>
				<view class="box">
					<uni-icons type="download" size="26"></uni-icons>
					<text class="text">下载</text>
				</view>
			</view>
		</view>
		<!-- 壁纸信息底部popup -->
		<uni-popup ref="infoPopup" type="bottom" borderRadius="30rpx 30rpx 0 0" background-color="#fff" :safe-area="false">
			<view class="infoPopup">
				<view class="header">
					<view></view>
					<view class="title">
						壁纸信息
					</view>
					<view class="close" @click="closeInfoPopup">
						<uni-icons type="closeempty" size="20"></uni-icons>
					</view>
				</view>
				<view class="content">
					<scroll-view scroll-y="true">
						<view class="row">
							<view class="left">壁纸ID：</view>
							<view class="right">3489343493492392f2312</view>
						</view>
						<view class="row">
							<view class="left">发布者：</view>
							<view class="right">小咪想吃鱼</view>
						</view>
						<view class="row">
							<view class="left">评分：</view>
							<view class="right"><uni-rate :size="20" :value="5"/></view>
						</view>
						<view class="row">
							<view class="left">摘要：</view>
							<view class="right">张婧仪一袭金色礼服端庄大气。图源：微博@张婧仪</view>
						</view>
						<view class="row">
							<view class="left">标签：</view>
							<view class="right tags">
								<view class="tag">
									张婧仪
								</view>
								<view class="tag">
									美女女神
								</view>
							</view>
						</view>
					</scroll-view>
				</view>
			</view>
		</uni-popup>
		<!-- 评分居中popup -->
		<uni-popup ref="scorePopup" borderRadius="30rpx 30rpx 30rpx 30rpx" background-color="#fff">
			<view class="infoPopup scorePopup">
				<view class="header">
					<view></view>
					<view class="title">
						评分
					</view>
					<view class="close" @click="closeScorePopup">
						<uni-icons type="closeempty" size="20"></uni-icons>
					</view>
				</view>
				<view class="content">
					<uni-rate :size="32" v-model="score" allowHalf/>
					<button class="confrimRate" size="mini" @click="confrimRate" plain :disabled="score == 0">确认评分</button>
				</view>
			</view>
		</uni-popup>
	</view>
</template>

<script setup>
import {statusBarHeight,navBarHeight} from '../../utils/system.js'
import { ref } from 'vue';
const maskState = ref(true)
const infoPopup = ref(null)
const scorePopup = ref(null)
const score = ref(0)
const maskChange = () => {
	maskState.value = !maskState.value;
}
const openInfoPopup = () => {
	infoPopup.value.open();
}
const closeInfoPopup = () => {
	infoPopup.value.close();
}
const openScorePopup = () => {
	scorePopup.value.open();
}
const closeScorePopup = () => {
	scorePopup.value.close();
}
const confrimRate = () => {
	console.log('已评分',score.value);
}
const goBack = () => {
	uni.navigateBack()
}
</script>

<style lang="scss" scoped>
.preview {
	width: 100%;
	height: 100vh;
	position: relative;
	swiper {
		width: 100%;
		height: 100%;
		image {
			width: 100%;
			height: 100%;
		}
	}
	.mask {
		transition: opacity 0.2s ease-in;
		&>view {
			position: absolute;
			left: 50%;
			transform: translateX(-50%);
		}
		.goBack {
			width: 38px;
			height: 38px;
			background: rgba(0,0, 0, 0.5);
			left: 60rpx;
			margin-left: 0;
			border-radius: 100rpx;
			top: 0;
			backdrop-filter: blur(10rpx);
			border: 1rpx solid rgba(255,255, 255, 0.3);
			display: flex;
			align-items: center;
			justify-content: center;
		}
		.count {
			top: 10vh;
			left: 50%;
			transform: translateX(-50%);
			background: rgba(0,0, 0, 0.2);
			border-radius: 30rpx;
			padding: 8rpx 28rpx;
			width: fit-content;
			backdrop-filter: blur(10rpx);
			font-size: 28rpx;
			color: #fff;
		}
		.time {
			top: calc(10vh + 80rpx);
			width: fit-content;
			font-size: 140rpx;
			color: #fff;
			text-shadow: 0 4rpx rgba(0,0, 0, 0.3);
			font-weight: 100;
			line-height: 1em;
		}
		.date {
			top: calc(10vh + 240rpx);
			width: fit-content;
			font-size: 34rpx;
			color: #fff;
			text-shadow: 0 4rpx rgba(0,0, 0, 0.3);
		}
		.footer {
			background: rgba(255,255, 255, 0.8);
			bottom: 10vh;
			width: 65vw;
			height: 120rpx;
			display: flex;
			justify-content: space-around;
			align-items: center;
			border-radius: 120rpx;
			backdrop-filter: blur(20rpx);
			box-shadow: 0 2rpx 0 rgba(0,0, 0, 0.1);
			left: 50%;
			.box {
				display: flex;
				flex-direction: column;
				align-items: center;
				justify-content: center;
				padding: 2rpx 10rpx;
				.text {
					font-size: 26rpx;
					color: $text-font-color-2;
				}
			}
			
		}
	}
	.infoPopup {
		padding: 50rpx 46rpx;
		.header {
			display: flex;
			justify-content: space-between;
			align-items: center;
			.title {
				font-size: 32rpx;
				color: $text-font-color-2;
			}
			:deep() {
				.uni-icons {
					color: $text-font-color-2 !important;
				}
			}
			.close {
				padding: 0 15rpx;
			}
		}
		.content {
			margin-top: 50rpx;
			scroll-view {
				max-height: 50vh;
				.row {
					display: flex;
					align-items: center;
					padding: 16rpx 0;
					font-size: 30rpx;
					line-height: 1.7rem;
					.left {
						color: $text-font-color-3;
						text-align: right;
						width: 140rpx;
					}
					.right {
						flex: 1;
						color: $text-font-color-1;
						
					}
					.tags {
						display: flex;
						.tag {
							height: 50rpx;
							line-height: 50rpx;
							padding: 0 16rpx;
							border: 1px solid $brand-theme-color;
							border-radius: 50rpx;
							font-size: 24rpx;
							margin-left: 14rpx;
							&:first-child {
								margin-left: 0;
							}
						}
					}
				}
			}
		}
	}
	.scorePopup {
		width: 65vw;
		.content {
			display: flex;
			flex-direction: column;
			justify-content: center;
			align-items: center;
			.confrimRate {
				margin-top: 50rpx;
			}
		}
	}
}
</style>
